package com.jeesite.modules.storage.api;

import com.jeesite.modules.storage.common.ServerResponse;
import com.jeesite.modules.storage.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 销售Controller
 */
@RestController(value = "apiordersale")
@RequestMapping(value = "/api/order/sale")
public class SaleController extends APIController {

    @Autowired
    private OrderService orderService;

    /**
     * 统计汇总【日】
     * @param memberId 会员Id
     * @param dayDate 日期
     * @return 统计汇总
     */
    @RequestMapping(method = RequestMethod.GET,value = "day/statistics")
    @ResponseBody
    public ServerResponse<Map> dayStatistics(@RequestParam(value = "memberId")String memberId,@RequestParam(value = "dayDate")String dayDate){
        return ServerResponse.createBySuccess(200,orderService.getDaySaleStatistics(memberId,dayDate));
    }

    /**
     * 统计汇总【月】
     * @param memberId 会员Id
     * @param monthDate 日期
     * @return 统计汇总
     */
    @RequestMapping(method = RequestMethod.GET,value = "month/statistics")
    @ResponseBody
    public ServerResponse<Map> monthStatistics(@RequestParam(value = "memberId")String memberId,@RequestParam(value = "monthDate")String monthDate){
        return ServerResponse.createBySuccess(200,orderService.getMonthSaleStatistics(memberId,monthDate));
    }

    /**
     * 统计汇总【年】
     * @param memberId 会员Id
     * @param yearDate 日期
     * @return 统计汇总
     */
    @RequestMapping(method = RequestMethod.GET,value = "year/statistics")
    @ResponseBody
    public ServerResponse<Map> yearStatistics(@RequestParam(value = "memberId")String memberId,@RequestParam(value = "yearDate")String yearDate){
        return ServerResponse.createBySuccess(200,orderService.getYearSaleStatistics(memberId,yearDate));
    }

    /**
     * 查询列表【日】
     * @param memberId 会员Id
     * @param dayDate 每日日期
     * @param size 每页数量
     * @param page 页码
     * @return 销售列表
     */
    @RequestMapping(method = RequestMethod.GET,value = "day/query")
    @ResponseBody
    public ServerResponse<List<Map>> dayQuery(@RequestParam(value = "memberId")String memberId,@RequestParam(value = "dayDate")String dayDate, @RequestParam(value="size",defaultValue = "10") Integer size, @RequestParam(value="page",defaultValue = "1") Integer page){
        return ServerResponse.createBySuccess(200,orderService.getDaySaleList(memberId,dayDate,size,page));
    }

    /**
     * 查询列表【月】
     * @param transMemberId 转发会员Id
     * @param memberId 会员Id
     * @param monthDate 每日日期
     * @param size 每页数量
     * @param page 页码
     * @return 销售列表
     */
    @RequestMapping(method = RequestMethod.GET,value = "month/query")
    @ResponseBody
    public ServerResponse<List<Map>> monthQuery(@RequestParam(value = "transMemberId",required = false)String transMemberId,@RequestParam(value = "memberId")String memberId,@RequestParam(value = "monthDate")String monthDate, @RequestParam(value="size",defaultValue = "10") Integer size, @RequestParam(value="page",defaultValue = "1") Integer page){
        return ServerResponse.createBySuccess(200,orderService.getMonthSaleList(memberId,monthDate,size,page));
    }

    /**
     * 查询列表【年】
     * @param memberId 会员Id
     * @param monthDate 每日日期
     * @param size 每页数量
     * @param page 页码
     * @return 销售列表
     */
    @RequestMapping(method = RequestMethod.GET,value = "year/query")
    @ResponseBody
    public ServerResponse<List<Map>> yearQuery(@RequestParam(value = "memberId")String memberId,@RequestParam(value = "monthDate")String monthDate, @RequestParam(value="size",defaultValue = "10") Integer size, @RequestParam(value="page",defaultValue = "1") Integer page){
        return ServerResponse.createBySuccess(200,orderService.getYearSaleList(memberId,monthDate,size,page));
    }
}
